######################################################################
#
#    Author :  Ao Zhang
#    E-mail :  nlp410.cn@gmail.com
#
#    Date   :  Mar. 24, 2012
#
#    Description :
#        A counter for lines, words or something else.
#
######################################################################

class counter:
	information = ''
	number      = 0
	step        = 1000

	def __init__( self, step=1000, num=0, info = '' ):
		self.step   = step
		self.number = num
		if info == '' or info.find( '%d' ) < 0:
			self.information = '\rProcessed %d lines.'

	def adder( self ):
		self.number += 1

	def print_info( self ):
		if self.number % self.step == 0:
			print( self.information % self.number, end = '' )

	def done( self ):
		print( self.information % self.number, end = '' )
		print( ' Done!' )

	def get_number( self ):
		return self.number
